package org.example;

public class PokeCreate {


    /**
     * 使用几副扑克牌
     * 去掉大小王
     */
    public Integer pokeAllNumber;

    /**
     * 牌堆
     * ['黑桃A','黑桃A','红桃A','红桃A','方块A','方块A','梅花A','梅花A','黑桃2','黑桃2','红桃2','红桃2','方块2','方块2','梅花2','梅花2']
     */
    public PokeBean[] pokeBeanArray;
    public static PokeBean[] pokeBeanStaticArray;

    public PokeCreate(Integer pokeAllNumber) {
        this.pokeAllNumber = pokeAllNumber;
        this.pokeBeanArray = new PokeBean[52 * pokeAllNumber];
        initPokeConstant();
    }

    public void initPokeConstant(){
        // 扑克牌一轮花色是1~13，一副扑克牌有4个花色，那就是13*4=52
        // A、2、3、4、5、6、7、8、9、10、J、Q、K
        PokeBean[] init = new PokeBean[13];
        for (int i = 0; i < init.length; i++) {
            if (i == 0) {
                init[i] = new PokeBean("A", 1);
            } else if (i == 10) {
                init[i] = new PokeBean("J", 10);
            } else if (i == 11) {
                init[i] = new PokeBean("Q", 10);
            } else if (i == 12) {
                init[i] = new PokeBean("K", 10);
            } else {
                init[i] = new PokeBean(String.valueOf(i + 1), i + 1);
            }
        }


        // 排堆当前的下标
        int curr = 0;
        // 扑克牌1~13的牌循环
        for (int number = 0; number < init.length; number++) {//A、2
            // 花色循环
            for (int j = 1; j <= 4; j++) {//黑桃、红桃、方块、梅花
                // 当前遍历的花色是xxx
                ColorEnum colorEnum = ColorEnum.getColorEnum(j);
                PokeBean pokeBean = init[number];
                pokeBean.setColor(colorEnum);
                for (int i = 0; i < pokeAllNumber; i++) {
                    pokeBeanArray[curr++] = pokeBean;
                }
            }
        }
    }

}
